﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogicUniversityBiz;
namespace LogicUniversity.Department_Head
{
    public partial class Reorder_Report : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public bool checkDateTime(DateTime firstDate, DateTime secondDate, DateTime thirdDate)
        {

            if (firstDate.Month <= DateTime.Now.Month && firstDate.Year <= DateTime.Now.Year && secondDate.Year <= DateTime.Now.Year && secondDate.Month <= DateTime.Now.Month && thirdDate.Month <= DateTime.Now.Month && thirdDate.Year <= DateTime.Now.Year)
            {
                return true;
            }
            return false;
        }
        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            try
            {

                DateTime firstDate = DateTime.ParseExact(txtFirstMonth.Text, "M/d/yyyy", null);
                DateTime secondDate = DateTime.ParseExact(txtSecondMonth.Text, "M/d/yyyy", null);
                DateTime thirdDate = DateTime.ParseExact(txtThirdMonth.Text, "M/d/yyyy", null);
                if (checkDateTime(firstDate, secondDate, thirdDate))
                {
                    //if (ddlReportType.SelectedItem.Value.Equals("monthlyRequisiton"))
                    //{
                    ReportController rController = new ReportController();
                    DeptMonthlyRequest depMothly = new DeptMonthlyRequest();
                    depMothly.SetDataSource(rController.getReOrderMonthlyReport(firstDate.Month, secondDate.Month, thirdDate.Month));
                    crvDeptMonthlyRequisition.ReportSource = depMothly;
                    crvDeptMonthlyRequisition.RefreshReport();
                    //}
                    //else if (ddlReportType.SelectedItem.Value.Equals("reorderReport"))
                    //{
                    //    ReportController rController = new ReportController();
                    //    DeptMonthlyRequest depMothly = new DeptMonthlyRequest();
                    //    depMothly.SetDataSource(rController.getReOrderMonthlyReport(firstDate.Month, secondDate.Month, thirdDate.Month));
                    //    crvDeptMonthlyRequisition.ReportSource = depMothly;
                    //    crvDeptMonthlyRequisition.RefreshReport();
                    //}
                }
            }
            catch (Exception ex)
            {

            }
        }
    }
}